home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk4 / patch / common.h next >
C/C++ Source or Header  |  1995-03-18  |  4KB  |  167 lines

  1. /* $Header: common.h,v 2.0 86/09/17 15:36:39 lwall Exp $
  2.  *
  3.  * $Log:    common.h,v $
  4.  * Revision 2.0  86/09/17  15:36:39  lwall
  5.  * Baseline for netwide release.
  6.  * 
  7.  */
  8.  
  9. #define DEBUGGING
  10.  
  11. #include "config.h"
  12.  
  13. /* shut lint up about the following when return value ignored */
  14.  
  15. #define Signal (void)signal
  16. #define Unlink (void)unlink
  17. #define Lseek (void)lseek
  18. #define Fseek (void)fseek
  19. #define Fstat (void)fstat
  20. #define Pclose (void)pclose
  21. #define Close (void)close
  22. #define Fclose (void)fclose
  23. #define Fflush (void)fflush
  24. #define Sprintf (void)sprintf
  25. #define Mktemp (void)mktemp
  26. #define Strcpy (void)strcpy
  27. #define Strcat (void)strcat
  28.  
  29. #ifdef AMIGA
  30. #include <exec/types.h>
  31. #include <dos.h>
  32. #include <stdio.h>
  33. #include <assert.h>
  34. #include <ctype.h>
  35. #include <signal.h>
  36. #include <string.h>
  37. #include <stdlib.h>
  38. #else
  39. #include <stdio.h>
  40. #include <assert.h>
  41. #include <sys/types.h>
  42. #include <sys/stat.h>
  43. #include <ctype.h>
  44. #include <signal.h>
  45. #endif
  46.  
  47. /* constants */
  48.  
  49. #ifndef AMIGA
  50. #define TRUE (1)
  51. #define FALSE (0)
  52. #endif
  53.  
  54. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  55. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  56. #define MAXLINELEN 1024
  57. #define BUFFERSIZE 1024
  58. #define ORIGEXT ".orig"
  59. #define SCCSPREFIX "s."
  60. #define GET "get -e %s"
  61. #define RCSSUFFIX ",v"
  62. #define CHECKOUT "co -l %s"
  63.  
  64. /* handy definitions */
  65.  
  66. #define Null(t) ((t)0)
  67. #define Nullch Null(char *)
  68. #define Nullfp Null(FILE *)
  69. #define Nulline Null(LINENUM)
  70.  
  71. #define Ctl(ch) ((ch) & 037)
  72.  
  73. #define strNE(s1,s2) (strcmp(s1, s2))
  74. #define strEQ(s1,s2) (!strcmp(s1, s2))
  75. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  76. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  77.  
  78. /* typedefs */
  79.  
  80. typedef char bool;
  81. typedef long LINENUM;            /* must be signed */
  82. typedef unsigned MEM;            /* what to feed malloc */
  83.  
  84. /* globals */
  85.  
  86. EXT int Argc;                /* guess */
  87. EXT char **Argv;
  88. EXT int Argc_last;            /* for restarting plan_b */
  89. EXT char **Argv_last;
  90.  
  91. #ifdef AMIGA
  92. EXT struct FILEINFO filestat;
  93. #else
  94. EXT struct stat filestat;        /* file statistics area */
  95. #endif
  96. EXT int filemode INIT(0644);
  97.  
  98. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  99. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  100. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  101.  
  102. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  103. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  104.  
  105. #define MAXFILEC 2
  106. EXT int filec INIT(0);            /* how many file arguments? */
  107. EXT char *filearg[MAXFILEC];
  108. EXT bool ok_to_create_file INIT(FALSE);
  109. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  110.  
  111. EXT char *outname INIT(Nullch);
  112. EXT char rejname[128];
  113.  
  114. EXT char *origext INIT(Nullch);
  115.  
  116. #ifdef AMIGA
  117. EXT char TMPOUTNAME[] INIT(":t/patchoXXXXXX");
  118. EXT char TMPINNAME[] INIT(":t/patchiXXXXXX");    /* might want /usr/tmp here */
  119. EXT char TMPREJNAME[] INIT(":t/patchrXXXXXX");
  120. EXT char TMPPATNAME[] INIT(":t/patchpXXXXXX");
  121. #else
  122. EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
  123. EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");    /* might want /usr/tmp here */
  124. EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  125. EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
  126. #endif
  127. EXT bool toutkeep INIT(FALSE);
  128. EXT bool trejkeep INIT(FALSE);
  129.  
  130. EXT LINENUM last_offset INIT(0);
  131. #ifdef DEBUGGING
  132. EXT int debug INIT(0);
  133. #endif
  134. EXT LINENUM maxfuzz INIT(2);
  135. EXT bool force INIT(FALSE);
  136. EXT bool verbose INIT(TRUE);
  137. EXT bool reverse INIT(FALSE);
  138. EXT bool noreverse INIT(FALSE);
  139. EXT bool skip_rest_of_patch INIT(FALSE);
  140. EXT int strippath INIT(957);
  141. EXT bool canonicalize INIT(FALSE);
  142.  
  143. #define CONTEXT_DIFF 1
  144. #define NORMAL_DIFF 2
  145. #define ED_DIFF 3
  146. #define NEW_CONTEXT_DIFF 4
  147. EXT int diff_type INIT(0);
  148.  
  149. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  150. EXT char if_defined[128];        /* #ifdef xyzzy */
  151. EXT char not_defined[128];        /* #ifndef xyzzy */
  152. EXT char else_defined[] INIT("#else\n");/* #else */
  153. EXT char end_defined[128];        /* #endif xyzzy */
  154.  
  155. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  156.  
  157. #ifndef AMIGA
  158. char *malloc();
  159. char *realloc();
  160. char *strcpy();
  161. char *strcat();
  162. char *sprintf();        /* usually */
  163. long atol();
  164. long lseek();
  165. char *mktemp();
  166. #endif
  167.